package cn.redragon.soa.data.entity;

import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.TypeDef;

@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
@MappedSuperclass
@TypeDef(name = "json", typeClass = JsonStringType.class)
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@ToString(callSuper = true)
public class BaseEntity extends IdEntity {

    private static final long serialVersionUID = -890296460188603220L;

    @Column(name = "created_time", nullable = false, updatable = false)
    protected LocalDateTime createTime;

    @Column(name = "updated_time", nullable = false)
    protected LocalDateTime updateTime;

    @Column(name = "created_by", nullable = false, length = 64, updatable = false)
    protected String creator;

    @Column(name = "updated_by", nullable = false, length = 64)
    protected String updater;

    protected String brand;

}
